package com.cxb.java;

/**
 * @Classname Solution
 * @Date 2023/4/11 21:48
 * @Created by Administrator
 * @Description TODO
 */
public class Solution {
    public static void main(String[] args) {
        test();
    }

    public static void test() {
        Object o = new Object();
        new Thread(() -> {
            synchronized (o) {
                System.out.println("11111");
                try {
                    o.wait();
                    System.out.println("33333");
                } catch (InterruptedException e) {
                    System.out.println("异常" + e);
                }
            }
        }, "t1").start();

        new Thread(() -> {
            synchronized (o) {
                System.out.println("22222");
                o.notify();
                System.out.println("44444");
            }
        }, "t2").start();
    }
}
